<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <script src="./js/vue.js"></script>
</head>

<body>
    <div id="app">
        <btn-primary title="this is a title">
            <template v-slot:first>
                <ul>
                    <li v-for="item in 10" :key="item">{{item}}</li>
                </ul>
            </template>
            <template v-slot:last>
                <button>last</button>
            </template>
        </btn-primary>
        <btn-primary :title="msg" @change="change"></btn-primary>
    </div>
    <script>
        Vue.component("btn-primary", {
            data() {
                return {
                    count: 10
                }
            },
            props: ["title"],
            methods: {
                plus() {
                    this.count++;
                }
            },
            template: "<button @click='$emit(\"change\",count,++count)'><slot name='first'></slot><slot name='last'></slot></button>"
        })

        let vm = new Vue({
            el: "#app",
            data: {
                msg: "this is a msg"
            },
            methods: {
                change(...val) {
                    console.log("子组件传递过来的值" + val);
                }
            }
        })
    </script>
</body>

<html>